<?php
/**
 * Created by xiaosong
 * E-mail:4155433@gmail.com
 * Date: 2019/9/17
 * Time: 17:23
 */

namespace App\Services\common;


use App\Exceptions\api\BaseException;
use App\Models\User;

class UserService
{
    public function register(array $params)
    {
        return User::create($params);
    }

    public function getUser(int $user_id)
    {
        $map['id'] = $user_id;
        $user = User::where($map)->first();
        if (!$user){
            throw new BaseException('用户不存在');
        }

        if ($user['status'] != 1){
            throw new BaseException('账号被禁用!');
        }
        return $user;

    }


    public static function getUserInfo(string $field = '',int $user_id)
    {

    }

}